package com.example.calculator_backend.pojo;

import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.deser.std.NumberDeserializers;

/**
 * @description: 贷款计算请求参数
 * @author: hdr
 * @PACKAGE_NAME: com.example.calculator_backend.pojo
 * @DATE: 2025/8/11
 */
public class LoanRequest {

    private String loanType;         // 商业、公积金、组合
    private String repaymentType;    // 等额本息 / 等额本金
    
    @JsonProperty("years")
    private BigDecimal years;        // 贷款年限（支持小数，如0.25年=3个月）

    private BigDecimal amount;       // 贷款金额
    private BigDecimal rate;         // 年利率

    private BigDecimal businessAmount;   // 商业贷款金额
    private BigDecimal businessRate;     // 商业贷款利率
    private BigDecimal providentAmount;  // 公积金贷款金额
    private BigDecimal providentRate;    // 公积金贷款利率

    // 可选：提前还款设置
    private Integer prepaymentMonth;         // 提前还款月份（从1开始）
    private BigDecimal prepaymentAmount;     // 提前还款金额
    private String prepaymentStrategy;       // 提前还款策略："缩短期限" / "减少月供"

    // 可选：先息后本设置
    private Integer interestOnlyMonths;      // 先息期（月），不填默认=总期限

    // 构造函数
    public LoanRequest() {}

    public LoanRequest(String loanType, String repaymentType, BigDecimal years, BigDecimal amount, BigDecimal rate) {
        this.loanType = loanType;
        this.repaymentType = repaymentType;
        this.years = years;
        this.amount = amount;
        this.rate = rate;
    }

    public LoanRequest(String loanType, String repaymentType, BigDecimal years, 
                      BigDecimal businessAmount, BigDecimal businessRate,
                      BigDecimal providentAmount, BigDecimal providentRate) {
        this.loanType = loanType;
        this.repaymentType = repaymentType;
        this.years = years;
        this.businessAmount = businessAmount;
        this.businessRate = businessRate;
        this.providentAmount = providentAmount;
        this.providentRate = providentRate;
    }

    // Getter 和 Setter 方法
    public String getLoanType() {
        return loanType;
    }

    public void setLoanType(String loanType) {
        this.loanType = loanType;
    }

    public String getRepaymentType() {
        return repaymentType;
    }

    public void setRepaymentType(String repaymentType) {
        this.repaymentType = repaymentType;
    }

    public BigDecimal getYears() {
        return years;
    }

    public void setYears(BigDecimal years) {
        this.years = years;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public BigDecimal getRate() {
        return rate;
    }

    public void setRate(BigDecimal rate) {
        this.rate = rate;
    }

    public BigDecimal getBusinessAmount() {
        return businessAmount;
    }

    public void setBusinessAmount(BigDecimal businessAmount) {
        this.businessAmount = businessAmount;
    }

    public BigDecimal getBusinessRate() {
        return businessRate;
    }

    public void setBusinessRate(BigDecimal businessRate) {
        this.businessRate = businessRate;
    }

    public BigDecimal getProvidentAmount() {
        return providentAmount;
    }

    public void setProvidentAmount(BigDecimal providentAmount) {
        this.providentAmount = providentAmount;
    }

    public BigDecimal getProvidentRate() {
        return providentRate;
    }

    public void setProvidentRate(BigDecimal providentRate) {
        this.providentRate = providentRate;
    }

    public Integer getPrepaymentMonth() {
        return prepaymentMonth;
    }

    public void setPrepaymentMonth(Integer prepaymentMonth) {
        this.prepaymentMonth = prepaymentMonth;
    }

    public BigDecimal getPrepaymentAmount() {
        return prepaymentAmount;
    }

    public void setPrepaymentAmount(BigDecimal prepaymentAmount) {
        this.prepaymentAmount = prepaymentAmount;
    }

    public String getPrepaymentStrategy() {
        return prepaymentStrategy;
    }

    public void setPrepaymentStrategy(String prepaymentStrategy) {
        this.prepaymentStrategy = prepaymentStrategy;
    }

    public Integer getInterestOnlyMonths() {
        return interestOnlyMonths;
    }

    public void setInterestOnlyMonths(Integer interestOnlyMonths) {
        this.interestOnlyMonths = interestOnlyMonths;
    }

    @Override
    public String toString() {
        return "LoanRequest{" +
                "loanType='" + loanType + '\'' +
                ", repaymentType='" + repaymentType + '\'' +
                ", years=" + years +
                ", amount=" + amount +
                ", rate=" + rate +
                ", businessAmount=" + businessAmount +
                ", businessRate=" + businessRate +
                ", providentAmount=" + providentAmount +
                ", providentRate=" + providentRate +
                ", prepaymentMonth=" + prepaymentMonth +
                ", prepaymentAmount=" + prepaymentAmount +
                ", prepaymentStrategy='" + prepaymentStrategy + '\'' +
                ", interestOnlyMonths=" + interestOnlyMonths +
                '}';
    }
}
